﻿


using Net.http;
using System.Collections.Generic;

namespace HBase {
    [RoutePrefix("open")]
    public class HServer :BaseApiController {

        //Sys/showLog
        [HttpGet, Route("logger")]
        public BaseResult all() {
            return BaseResult.Ok(LoggerCache.getAll());
        }
        [HttpGet, Route("task")]
        public BaseResult getStat() {
            return BaseResult.Ok(TaskPool.getStat());
        }
        [HttpGet, Route("c/{key}")]
        public BaseResult getCache(string key) {
            if( string.IsNullOrWhiteSpace(key) ) {
                return BaseResult.Ok(MyCache.getAll());
            } else {
                MyDict<string ,object> res = new MyDict<string ,object>();
                string[] keys = key.Split(':');
                foreach( string k in keys ) {
                    if( string.IsNullOrWhiteSpace(key) ) {
                        continue;
                    }
                    res.addOverride(k ,MyCache.getAll(k));
                }
                return BaseResult.Ok(res);
            }
        }
        [HttpGet, Route("stop")]
        public BaseResult stop() {
            BaseConfig.Working = false;
            TaskPool.setInit();
            return BaseResult.Ok("");
        }
        [HttpGet, Route("running")]
        public BaseResult running() {
       
            return BaseResult.Ok(BaseConfig.Working);
        }
        [HttpGet, Route("setrunning")]
        public BaseResult setTunning() {
            BaseConfig.Working = true;
            return BaseResult.Ok(BaseConfig.Working);
        }
    }

}
